package nbcb;

import java.util.Scanner;

public class M {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num;
        int n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            num = 0;
            char[] s = sc.nextLine().toCharArray();
            for (char c : s) {
                if (Character.isDigit(c)) num++;
            }
            System.out.println(num);
        }
    }
}
